// import Taro, { request } from '@tarojs/taro';
import type { RequestConfig } from 'types/request'
import { post } from '@/utils/request'

interface LoginResult {
  openid: string
  token: string
  /**客户ID */
  customer_id: string
  /**客户姓名 */
  customer_name: string
}

export function login(
  data: {
    appId: string
    // appSecret 小程序密钥，不给将使用服务器配置
    // secret?: string;
    // js_code: string;
    openid: string

    iv: string
    encryptedData: string
  },
  config?: RequestConfig,
): Promise<LoginResult>
export function login(data, config) {
  return post('/applets_login/wxLogin', data, config)
}

/**
 * 直接登录，或者判断是否登录
 *
 */
export default function getOpenid(data: { appId: string; js_code: string }): Promise<LoginResult>
export default function getOpenid(data) {
  return post('/applets_login/getopenid', data)
}
